import org.springframework.stereotype.Service;

<#--类路径-->
        package ${packageName}.service.impl;

<#--导包-->
<#list metaData.importClassPaths as icp>
        {icp};
</#list>
        {packageName}.pojo.${metaData.className};
        {packageName}.dao.${metaData.className}Dao;
        {packageName}.service.${metaData.className}Service;

/**
 * 注释: ${metaData.classComment} ServiceImpl实现类
 * Table: ${metaData.classMetaData.tableName}表业务实现类
 *
 * @author: ${author}
 * @version: ${version}
 * @time: ${dateFormat2}
 */
@Service
public class ${metaData.className}ServiceImpl implements ${metaData.className}Service {

    @Autowired
    private ${metaData.className}Dao ${metaData.className?uncap_first}Dao;

    /**
     * 通过ID查询单条数据
     *
<#list metaData.pk as pk>
     * @param ${pk.fieldName} 主键
</#list>
     * @return 实例对象
     */
    @Override
    public ${metaData.className} queryById(<#list metaData.pk as pk>${pk.fieldType} ${pk.fieldName}<#if pk_has_next>,</#if></#list>) {
        return this.${metaData.className?uncap_first}Dao.queryById(<#list metaData.pk as pk>${pk.fieldName}<#if pk_has_next>,</#if></#list>);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<${metaData.className}> queryAllByLimit(int offset, int limit) {
        return this.${metaData.className?uncap_first}Dao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ${metaData.className?uncap_first} 实例对象
     * @return 实例对象
     */
    @Override
    public ${metaData.className} insert(${metaData.className} ${metaData.className?uncap_first}) {
        this.${metaData.className?uncap_first}Dao.insert(${metaData.className?uncap_first});
        return ${metaData.className?uncap_first};
    }

    /**
     * 修改数据
     *
     * @param ${metaData.className?uncap_first} 实例对象
     * @return 实例对象
     */
    @Override
    public ${metaData.className} update(${metaData.className} ${metaData.className?uncap_first}) {
        this.${metaData.className?uncap_first}Dao.update(${metaData.className?uncap_first});
        return this.queryById(${metaData.className?uncap_first}.getId());
    }

    /**
     * 通过主键删除数据
     *
<#list metaData.pk as pk>
     * @param ${pk.fieldName} 主键
</#list>
     * @return 是否成功
     */
    @Override
    public boolean deleteById(<#list metaData.pk as pk>${pk.fieldType} ${pk.fieldName}<#if pk_has_next>,</#if></#list>) {
        return this.${metaData.className?uncap_first}Dao.deleteById(<#list metaData.pk as pk>${pk.fieldName}<#if pk_has_next>,</#if></#list>) > 0;
    }
}